package com.example.mvc.controller;

import com.example.mvc.bean.History;
import com.example.mvc.bean.User;
import com.example.mvc.service.BookBorrowService;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;

import java.io.IOException;
import java.util.List;

@WebServlet("/borrowRecordListServlet")
public class BorrowRecordListServlet extends HttpServlet {
    BookBorrowService bookBorrowService = new BookBorrowService();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String bookId = req.getParameter("bookId");
        List<History> bookHistoryStatusList = bookBorrowService.borrowRecordListServlet(Integer.parseInt(bookId));
        HttpSession session = req.getSession();
        session.setAttribute("bookHistoryStatusList", bookHistoryStatusList);

        req.getRequestDispatcher("/admin_blog.jsp").forward(req,resp);

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req,resp);

    }

}